package com.soundShape.utils
{
	import com.soundShape.model.ApplicationModel;
	import com.soundShape.vo.CustomerVO;
	
	import mx.collections.ArrayCollection;
	
	import nz.co.codec.flexorm.criteria.Criteria;

	public class CustomerUtil
	{
		[Inject]
		public var applicationModel:ApplicationModel;
		
		public function CustomerUtil()
		{
		}
		
		[EventHandler(event="SoundShapeEvent.GET_CUSTOMERS")]
		public function getCustomers():void
		{
			var criteria:Criteria = applicationModel.entityManager.createCriteria(CustomerVO);
			
			if(applicationModel.customers != null)
			{
				applicationModel.customers.removeAll();
				applicationModel.customers.refresh();
			}
			
			applicationModel.customers = applicationModel.entityManager.fetchCriteria(criteria);
			applicationModel.customers.refresh();
		}
	}
}